<?php
// +----------------------------------------------------------------------
// | ThinkBLOG (Build on ThinkPHP)
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author nicholas <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: IndexAction.class.php 113 2012-04-12 09:29:09Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class IndexAction extends AdminBaseAction {
	
	public function index() {
		$this->assign ( 'privacy', tprivacy () );
		$this->assign ( 'ur_here', array ('text' => L ( '_HERE_INDEX_' ), 'action' => 'index' ) );
		$this->display ();
	}
	
	public function info() {
		
		$db = Db::getInstance ();
		$db_ver = $db->query ( 'select version();' );
		$db_ver = $db_ver [0] ['version()'];
		
		$db_size = 0;
		$row = $db->query ( "SHOW TABLE STATUS LIKE '" . C ( 'DB_PREFIX' ) . "%'" );
		foreach ( $row as $val ) {
			$db_size += $val ['Data_length'] + $val ['Index_length'];
		}
		$db_size = $db_size ? tnum_bitunit ( $db_size ) : L ( '_UNKNOWN_SIZE_' );
		
		$ft = gd_info ();
		$gd = tgdversion ();
		
		if ($gd == 0) {
			$sys_info ['gd'] = 'N/A';
		} else {
			if ($gd == 1) {
				$sys_info ['gd'] = 'GD1';
			} else {
				$sys_info ['gd'] = 'GD2';
			}
			
			$sys_info ['gd'] .= ' (';
			
			if ($gd && (imagetypes () & IMG_JPG) > 0) {
				$sys_info ['gd'] .= ' JPEG';
			}
			
			if ($gd && (imagetypes () & IMG_GIF) > 0) {
				$sys_info ['gd'] .= ' GIF';
			}
			
			if ($gd && (imagetypes () & IMG_PNG) > 0) {
				$sys_info ['gd'] .= ' PNG';
			}
			
			$sys_info ['gd'] .= ')';
		}
		
		$sys_info ['os'] = PHP_OS;
		$sys_info ['ip'] = $_SERVER ['SERVER_ADDR'];
		$sys_info ['web_server'] = $_SERVER ['SERVER_SOFTWARE'];
		$sys_info ['php_ver'] = PHP_VERSION;
		$sys_info ['mysql_ver'] = $db_ver;
		$sys_info ['php_handler'] = php_sapi_name ();
		$sys_info ['ThinkPHP'] = THINK_VERSION . ' [ <a href="http://thinkphp.cn" target="_blank">' . L ( '_THINKPHP_NEW_VERSION_' ) . '</a> ]';
		$sys_info ['http'] = $_SERVER ['SERVER_PROTOCOL'];
		$sys_info ['root'] = $_SERVER ['DOCUMENT_ROOT'];
		$sys_info ['max_filesize'] = ini_get ( 'file_uploads' ) ? ini_get ( 'upload_max_filesize' ) : '<span>Disabled</span>';
		$sys_info ['max_execution_time'] = ini_get ( 'max_execution_time' ) . ' seconds';
		$sys_info ['Zend_Optimizer'] = defined ( 'OPTIMIZER_VERSION' ) ? OPTIMIZER_VERSION : L ( '_NO_ZEND_OPTIMIZER_' );
		$sys_info ['FreeType'] = $ft ['FreeType Support'] ? '<span>Supported</span>' : '<span>Not supported</span>';
		$sys_info ['register_globals'] = get_cfg_var ( 'register_globals' ) ? L ( '_YES_' ) : L ( '_NO_' );
		$sys_info ['zlib'] = function_exists ( 'gzclose' ) ? L ( '_YES_' ) : L ( '_NO_' );
		$sys_info ['safe_mode'] = ( boolean ) ini_get ( 'safe_mode' ) ? L ( '_YES_' ) : L ( '_NO_' );
		$sys_info ['safe_mode_gid'] = ( boolean ) ini_get ( 'safe_mode_gid' ) ? L ( '_YES_' ) : L ( '_NO_' );
		$sys_info ['timezone'] = function_exists ( 'date_default_timezone_get' ) ? date_default_timezone_get () : L ( '_NO_TIMEZONE_' );
		$sys_info ['socket'] = function_exists ( 'fsockopen' ) ? L ( '_YES_' ) : L ( '_NO_' );
		$sys_info ['dbsize'] = $db_size;
		$sys_info ['install_date'] = tlocal_date ( 'Y-m-d', C ( 'installDate' ) );
		$sys_info ['ThinkBLOG_charset'] = strtoupper ( C ( 'THINKBLOG_CHARSET' ) );
		$sys_info ['ThinkBLOG_version'] = C ( 'THINKBLOG_VERSION' ) . ' Build ' . C ( 'THINKBLOG_RELEASE' ) . ' [ <a href="http://www.yurnero.net" target="_blank">' . L ( '_THINKPHP_NEW_VERSION_' ) . '</a> ]' . ' [ <a href="' . C ( 'THINKBLOG_CODE' ) . '" target="_blank">' . L ( '_SVN_' ) . '</a> ]';
		
		$this->assign ( 'sys_info', $sys_info );
		$this->assign ( 'ur_here', array ('text' => L ( '_HERE_INFO_' ), 'action' => 'tools' ) );
		$this->display ();
	}

}